package com.sdry.web.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sdry.base.BaseController;
import com.sdry.entity.PartOrderDetail;
import com.sdry.entity.PartOrderDetailExample;
import com.sdry.entity.PartOrderDetailExample.Criteria;
import com.sdry.service.PartOrderDetailService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 采购单详情
 * 
 * @AUTHOR HACKER
 */
@Api(value = "采购单详情")
@Controller
@RequestMapping("/purchase/orderdetail")
public class PartOrderDetailController extends BaseController {

	@Autowired
	private PartOrderDetailService partOrderDetailService;

	/**
	 * 列表
	 */
	@ApiOperation(value = "列表")
	@RequestMapping(value = "/list/{id}", method = RequestMethod.GET)
	@ResponseBody
	public Object list(@PathVariable("id") Long id) {
		PartOrderDetailExample example = new PartOrderDetailExample();
		Criteria criteria = example.createCriteria();
		criteria.andOrderIdEqualTo(id);

		List<PartOrderDetail> rows = partOrderDetailService.selectByExample(example);
		long total = partOrderDetailService.countByExample(example);
		Map<String, Object> result = new HashMap<>();
		result.put("rows", rows);
		result.put("total", total);
		return result;
	}

}
